object ForComprehensionDemo extends App {
  val rawScores: List[Double] = List(75.0, 82.5, 90.0, 68.0, 85.5, 79.0, 92.0)
  val standardScores = for (score <- rawScores) yield score * 0.8 + 20
  println(s"原始分数: $rawScores")
  println(s"标准分数: $standardScores")
  val excellentScores = for {
    score <- standardScores
    if score >= 80
  } yield score
  println(s"优秀标准分(≥80): $excellentScores")
  val scoreDetails = for {
    raw <- rawScores
    standard = raw * 0.8 + 20
  } yield (raw, standard, if (standard >= 80) "达标" else "未达标")
  println("\n成绩详情: ")
  scoreDetails.foreach { case (raw, std, status) =>
    println(s"原始分: $raw%.1f -> 标准分: $std%.1f (${status})")
  }
  val avgExcellent = if (excellentScores.nonEmpty) {
    excellentScores.sum / excellentScores.length
  } else 0.0
  println(f"\n优秀学生标准分平均分: $avgExcellent%.1f")
}